//
//  ListConversationController.m
//  PaiQuan
//
//  Created by Mac on 16/7/7.
//  Copyright © 2016年 huigu. All rights reserved.
//

#import "ListConversationController.h"
#import "ConversationViewController.h"
#import <RongIMKit/RongIMKit.h>
@interface ListConversationController ()

@end

@implementation ListConversationController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.conversationListTableView.backgroundColor = PQ_COLOR_DarkGray;
    [self.emptyConversationView removeFromSuperview];
    [self setDisplayConversationTypes:@[@(ConversationType_PRIVATE),
                                         @(ConversationType_DISCUSSION),
                                         @(ConversationType_CHATROOM),
                                         @(ConversationType_GROUP),
                                         @(ConversationType_APPSERVICE),
                                         @(ConversationType_SYSTEM)]];
     //设置需要将哪些类型的会话在会话列表中聚合显示
     [self setCollectionConversationType:@[@(ConversationType_DISCUSSION),
                                           @(ConversationType_GROUP)]];
    
}

- (void)onSelectedTableRow:(RCConversationModelType)conversationModelType
         conversationModel:(RCConversationModel *)model
               atIndexPath:(NSIndexPath *)indexPath {
    ConversationViewController *conversationVC = [[ConversationViewController alloc]init];
    conversationVC.conversationType = model.conversationType;
    conversationVC.targetId = model.targetId;
    
    conversationVC.title = @"名字";
    
    [super.navigationController setNavigationBarHidden:NO];
    
    [self.navigationController pushViewController:conversationVC animated:YES];
}
#pragma mark --自定义cell
-(CGFloat)rcConversationListTableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return RATIO(138);
}
-(UIColor *)cellBackgroundColor{
    return PQ_COLOR_DarkGray;
}
-(void)willDisplayConversationTableCell:(RCConversationBaseCell *)cell atIndexPath:(NSIndexPath *)indexPath
{
    RCConversationModel *model= self.conversationListDataSource[indexPath.row];
    if (model.conversationType == ConversationType_PRIVATE) {
        RCConversationCell *concell = (RCConversationCell *)cell;
        //标题
        concell.messageCreatedTimeLabel.translatesAutoresizingMaskIntoConstraints = YES;
        [concell.messageCreatedTimeLabel makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(concell.top).offset(RATIO(5));
            make.right.equalTo(concell.right).offset(-RATIO(20));
            
        }];
    
        
        [concell.conversationTitle setTextColor:[UIColor whiteColor]];
        [concell.conversationTitle setFont:FONT(32)];
        [concell.messageContentLabel setTextColor:PQ_COLOR_SimpleGary];
        [concell.messageContentLabel setFont:FONT(RATIO(28))];
        //内容
      
     
               //button
        UIButton *rightBtn = [[UIButton alloc] init];
        rightBtn.backgroundColor = [UIColor yellowColor];
        [concell addSubview:rightBtn];
        rightBtn.layer.cornerRadius = 10;
        rightBtn.layer.masksToBounds = YES;
        [rightBtn makeConstraints:^(MASConstraintMaker *make) {
            make.width.height.equalTo(RATIO(50));
            make.right.equalTo(concell.right).offset(-RATIO(20));
            make.bottom.equalTo(concell.bottom).offset(-RATIO(20));
        }];
        
        UIButton *leftBtn = [[UIButton alloc] init];
        leftBtn.backgroundColor = [UIColor redColor];
        [concell addSubview:leftBtn];
        leftBtn.layer.cornerRadius = 10;
        leftBtn.layer.masksToBounds = YES;
        [leftBtn makeConstraints:^(MASConstraintMaker *make) {
            make.width.height.equalTo(RATIO(50));
            make.right.equalTo(rightBtn.left).offset(-RATIO(16));
            make.bottom.equalTo(concell.bottom).offset(-RATIO(20));
        }];
        //headerView
        
        
        



        
        
    }
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
